import QtQuick 2.6

import "../Config"

Text {
    id:root
    property alias radius: background.radius
    QtObject {
        id : internal
        property double defaultDelay: 1500
        property double minimunHeight: 100 * Size.ratio
    }

    function show(txt, delay)
    {
        text = txt || ""
        timer.interval = delay || internal.defaultDelay
        root.visible = true
        timer.restart()
    }

    function hide()
    {
        root.visible = false
    }

    visible: false
    x : (parent.width - width) / 2
    y : (parent.height - height) / 2
    width: 400 * Size.ratio

    color: Color.messageBoxText
    font.pixelSize: Size.normalFont
    font.bold: true
    horizontalAlignment: Text.AlignHCenter
    verticalAlignment: Text.AlignVCenter

    onContentHeightChanged: height = contentHeight
    onHeightChanged: if(height < internal.minimunHeight)
                         height = internal.minimunHeight

    Rectangle {
        id:background
        anchors.fill: parent
        radius: 20 * Size.ratio
        color:Color.messageBoxBackground
        z:-1
    }
    Timer {
        id:timer
        running: false
        interval: internal.defaultDelay
        onTriggered: {
            root.visible = false;
        }
    }
}
